import { getDeviceRepairDetailApi } from '../api';
import { request } from '../../../../services/request';

// 诊断提交接口
export const diagnosisRepairApi = async (data: {
    id: string;
    error_reason: string;
    error_diag_desc: string;
    product_list: { product_id: string; quantity: number }[];
}) => {
    return request('/app/appDeviceInfo/diagnosisRepair', {
        method: 'POST',
        body: JSON.stringify(data),
    });
};

// 开始维修提交接口
export const beginRepairApi = async (data: {
    id: string;
    is_outsource: boolean;
    supplier_id: string;
    first_solution: string;
    final_solution: string;
    expect_end_time: string;
}) => {
    return request('/app/appDeviceInfo/beginRepair', {
        method: 'POST',
        body: JSON.stringify(data),
    });
};

// 完成维修提交接口
export const endRepairApi = async (data: {
    id: string;
    final_solution: string;
    service_fee: string;
    out_service_fee: string;
    service_desc: string;
    checker_desc: string;
    repair_link_list: { link: string }[];
}) => {
    return request('/app/appDeviceInfo/endRepair', {
        method: 'POST',
        body: JSON.stringify(data),
    });
};

// 供应商列表接口
export const searchSupplierApi = async (data: { current: number; size: number; keyword: string }) => {
    return request('/app/appCommon/searchSupplier', {
        method: 'POST',
        body: JSON.stringify(data),
    });
};

// 备品备件列表接口
export const searchProductApi = async (data: { current: number; size: number; keyword: string }) => {
    return request('/app/appDeviceInfo/getMaterialListPage', {
        method: 'POST',
        body: JSON.stringify(data),
    });
};

export { getDeviceRepairDetailApi }; 